//
//  CYGeRenZhuYe_GuanWangViewController.m
//  cyydt
//
//  Created by chu on 2019/1/28.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYGeRenZhuYe_GuanWangViewController.h"

@interface CYGeRenZhuYe_GuanWangViewController ()<WKNavigationDelegate>

@end

@implementation CYGeRenZhuYe_GuanWangViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    NSString *jScript =@"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta); var imgs = document.getElementsByTagName('img');for (var i in imgs){imgs[i].style.maxWidth='100%';imgs[i].style.height='auto';}";
    
    WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
    WKUserContentController *wkUController = [[WKUserContentController alloc] init];
    [wkUController addUserScript:wkUScript];
    
    WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
    
    wkWebConfig.userContentController = wkUController;
    
    self.WKWebView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) configuration:wkWebConfig];
    self.WKWebView.navigationDelegate = self;
    [self.WKWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]];
    self.WKWebView.opaque = NO;
    [self.view addSubview:self.WKWebView];
    
}


- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation {
    //修改字体大小 300%
    //    [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '100%'"completionHandler:nil];
    
    //修改字体颜色  #9098b8
    //    [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#FFFFFF'"completionHandler:nil];
    
}


- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
